<template>
    <div class="ChangeTable">
        <Row>
            <Col span="24">
                <Table
                    width="100%"
                    :columns="isSP ? contractTableHeadPartner : contractTableHead"
                    :data="contractTable.records"
                    :loading="loading"
                    border
                >
                    <template slot-scope="{ row, index }" slot="action">
                        <!--
                                处理  isViewBtn ~~审核中 待补件 待补件审核~~
                                编辑 草稿
                                删除 草稿
                            -->
                        <Button :disabled="!row.isViewBtn" type="primary" size="small" @click="handleRevoke(row)">处理
                        </Button>
                        <Button :disabled="row.processStatus !== 'draft'" type="primary" size="small" @click="handleRevoke(row)">编辑</Button>
                       <!--   <Button :disabled="row.processStatus !== 'draft'" type="error" size="small" @click="del(row)">删除</Button> -->

                        <Button type="primary" size="small" @click="detail(row)">分配明细</Button>
                    </template>
                    <template slot-scope="{ row, index }" slot="applyNo">
                        <a class="applyNo" @click="handleRevoke(row,'read')">{{row.applyNo}}</a>
                    </template>
                    <!-- 付款方式 -->
                    <template slot-scope="{ row, index }" slot="sourceType">
                        <span>{{getTitle('receiptSourceType',row.sourceType)}}</span>
                    </template>
                    <!-- 收款银行 -->
                    <template slot-scope="{ row, index }" slot="bankCode">
                        <span>{{getTitle('bankCode',row.bankCode)}}</span>
                    </template>
                    <!-- 状态 -->
                    <template slot-scope="{ row, index }" slot="processStatus">
                        <span>{{getTitle('processStatus',row.processStatus)}}</span>
                    </template>
                    <template slot-scope="{ row, index }" slot="arriveAmt">
                        <span>{{row.arriveAmt==""?"":row.arriveAmt.toFixed(2)}}</span>
                    </template>
                </Table>
            </Col>
            <Col span="24">
                <Row type="flex" justify="end" class="table-page">
                    <Page
                        :current="contractTable.current"
                        :transfer="true"
                        :total="contractTable.total"
                        :page-size="contractTable.size"
                        @on-change="changePage"
                        @on-page-size-change="changePageSize"
                        :page-size-opts="pageSizeOpts"
                        size="small"
                        show-total
                        show-elevator
                        show-sizer
                    ></Page>
                </Row>
            </Col>
        </Row>
    </div>
</template>
<script>
    import {getTitleFromDataDict} from "_p/basic/assets/contract/js/utils";

    export default {
        props: {
            formValidate: {
                type: Object,
                required: true
            },
            dataDict: {
                type: Object,
                required: true
            },
            contractTable: {
                type: Object,
                required: true
            },
            isSP: {
                type: Boolean,
                required: true,
            }
        },
        data() {
            return {
                // loading: false,
                pageSizeOpts: [10, 20, 50, 100],
                loading: false,
                contractTableHead: [
                    {
                        title: "操作",
                        slot: "action",
                        width: 220,
                        align: "center"
                    },
                    {
                        title: "申请号",
                        key: "applyNo",
                        slot: "applyNo",
                        minWidth: 120
                    },
                    {
                        title: "付款方式",
                        key: "sourceType",
                        slot: "sourceType",
                        minWidth: 120
                    },

                    {
                        title: "合同号",
                        key: "contractNo",
                        minWidth: 120
                    },
                    {
                        title: "案件号",
                        key: "caseNo",
                        minWidth: 120
                    },
                    {
                        title: "收款日期",
                        key: "succeedTime",
                        minWidth: 120
                    },
                    {
                        title: "收款金额",
                        key: "arriveAmt",
                        minWidth: 120
                    },

                    {
                        title: "处理状态",
                        key: "processStatus",
                        slot: "processStatus",
                        minWidth: 120
                    },
                    {
                        title: "案件发起时间",
                        key: "startTime",
                        minWidth: 120
                    },
                    {
                        title: "案件结束时间",
                        key: "endTime",
                        minWidth: 120
                    },
                ],
                contractTableHeadPartner: [
                    {
                        title: "操作",
                        slot: "action",
                        width: 180,
                        align: "center"
                    },
                    {
                        title: "申请号",
                        key: "applyNo",
                        slot: "applyNo",
                        minWidth: 120
                    },
                    {
                        title: "付款方式",
                        key: "sourceType",
                        slot: "sourceType",
                        minWidth: 120
                    },
                    {
                        title: "合同号",
                        key: "contractNo",
                        minWidth: 120
                    },
                    {
                        title: "收款日期",
                        key: "succeedTime",
                        minWidth: 120
                    },

                    {
                        title: "收款金额",
                        key: "arriveAmt",
                        slot: "arriveAmt",
                        minWidth: 120
                    },

                    {
                        title: "处理状态",
                        key: "processStatus",
                        slot: "processStatus",
                        minWidth: 120
                    },
                    {
                        title: "案件发起时间",
                        key: "startTime",
                        minWidth: 120
                    },
                    {
                        title: "案件结束时间",
                        key: "endTime",
                        minWidth: 120
                    },
                ]
            };
        },
        mounted() {
        },
        methods: {
            init() {
            },
            // 分页 Fn
            changePageSize(num) {
                this.$emit(
                    "getList",
                    Object.assign({}, this.formValidate, {pageSize: num})
                );
                this.formValidate.pageSize = num;
            },
            changePage(num) {
                this.$emit(
                    "getList",
                    Object.assign({}, this.formValidate, {pageNumber: num})
                );
                this.formValidate.pageNumber = num;
            },
            // 分配明细
            detail(row) {
                this.$emit("showDetail", row);
            },
            handleRevoke(row, readOnly) {
                this.$emit("handleRevoke", row, readOnly);
            },
            getTitle(type, val) {
                let data = this.dataDict[type + "Dict"] || [];
                return getTitleFromDataDict(data, val);
            }
        }
    };
</script>
<style scoped>
</style>
